import { createTrpcContext, testRouter } from '@/app/trpc/server';
import { getServerSession } from '@/server/auth';
import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
import { NextRequest } from 'next/server';

const handler = (request: NextRequest) => {
  return fetchRequestHandler({
    endpoint: '/api/trpc',
    req: request,
    router: testRouter,
    // 通过创建 trpc handler 的 createContext 去完成获取用户信息的公共逻辑
    createContext: createTrpcContext,
  });
};

export { handler as GET, handler as POST };
